<?php
class admin {
	//登陆
	function checklogin($user,$pass,$code=""){
		
		$db = new mysql();
		
		if(empty($user)||empty($pass)||empty($code)){
			YKT_error('登陆失败','/'.ADMINROOT.'/');
			exit();
		}else{
			if(get_magic_quotes_gpc()){
				$user = stripslashes($user);
			}else{
				$user = mysql_real_escape_string($user);
			}
			$pass=md5($pass);
			$admin=$db->getarray($db->query("select * from sysadmin where (sysadmin1='".$user."') and (sysadmin2='".$pass."') limit 1"));
			if(is_array($admin)){
				if(!isset($_SESSION)){
				session_start();
				}
				$_SESSION[ADMINSESSION]=$admin;
				$db->query('update sysadmin set sysadmin7="'.time().'" where sysadmin0='.$admin['sysadmin0'].' limit 1');
				//$base->alert("登陆成功",0,"/YKTGuanLi/Main.html");
				header("Location:/".ADMINROOT."/main.html");
			}else{
				YKT_error('登陆失败','/'.ADMINROOT.'/');
			}
		}
	}
	// 判是否登陆
	function islogin(){
		if(!isset($_SESSION[ADMINSESSION])){
			return false;
		}else{
			return true;
		}
	}
}